Create a Custom Node from a MATLAB Simulink model
You can generate a DLL file for a Custom Node DLL from a TPT test frame model using the Simulink Coder or Embedded Coder. The so generated MATLAB FUSION DLL can then be applied to a Custom Node DLL, to run tests on the MATLAB/Simulink model.
Preconditions and constraints
- 32-bit or 64-bit version of MATLAB, R2011a or newer
- supported compilers: MS Windows SDK 7.1, MS VC++ 2010 or newer, MinWG 4.9 or newer
- installed Simulink Coder in MATLAB
- in case of ERT target: installed Embedded Coder in MATLAB
Build a MATLAB/Simulink model for FUSION
To create the MATLAB FUSION DLL, configure a MATLAB/Simulink Platform and click the Build model for FUSION button under Tools in the MATLAB/Simulink Platform Configuration dialog. This will generate a temporary model and trigger the code generation via the Simulink Coder or Embedded Coder. A message box appears. Click Yes if you want to create the FUSION Platform using the previously generated MATLAB FUSION DLL.
The generated MATLAB FUSION DLL provides access to online loggings as channels and offline loggings as measurements. Additionally, an Import Measurement assesslet, see Assesslet Types - Import Measurements, is automatically created when adding offline loggings as internal signals via the MATLAB/Simulink Platform configuration. This assesslet will not work when using the generated MATLAB FUSION DLL within a FUSION Platform.
Create a MATLAB/Simulink model for FUSION only
If you want to adjust the model manually before the code generation, select Create model for FUSION only. In this case, you need to build the generated model manually. TPT provides two targets/profiles for the Simulink Coder: fusion_grt.tlc
and fusion_ert.tlc
. The former one is based on the Simulink Coder's GRT target (grt.tlc
); the latter one is based on the Embedded Coder's ERT target (ert.tlc
). Both TPT targets automatically generate a FUSION Platformcompliant interface to the function or model into a DLL, combined with the model's code.
Generate the code with Simulink Coder/Embedded Coder
To manually generate the code with Simulink Coder / Embedded Coder, go to "Code Generation options" and another "System target file" in the "Target Selection" section.
- Go to "TPT options" and check the TPT installation path. It should have been set automatically when starting MATLAB from within TPT. However, it is possible to select a TPT installation or to manually edit the installation path.
- Click "Build" in the "Code Generation" section to start the generation of the MATLAB FUSION DLL. Make sure the option "Generate code only" is disabled.
Model parameters which will be exchanged between TPT and MATLAB FUSION DLL must be Simulink Parameter objects or they have to be declared in Simulink as global / tunable parameter. Go to "Optimization|Signals and Parameters" in the model settings in Simulink to make changes.
fusion_grt.tlc
or fusion_ert.tlc
targets, try generating code with grt.tlc
or ert.tlc
first to make sure your model is ready for code/DLL generation.Naming conventions for in- and outputs
- If the signal of an inport or outport block has a name, this name is used. Alternatively the name of the block is used.
- In case of identical variable names, a number is attached to the name (for example,
signal
,signal_2
,signal_3
) - Spaces or line breaks are not allowed in the names.
Apply the MATLAB FUSION DLL to a Custom Node
- Create a FUSION Platform.
- Add a Custom Node DLL.
- Select the MATLAB FUSION DLL in the Node DLL field.
The MATLAB FUSION DLL accepts three different arguments:
-pv
output of all FUSION Platformvariables (inputs, outputs, model parameter) related to your model with name, data type and so forth at the beginning of the test execution in the Build Progress dialog
-pc
output of the complete variable usage (read/write) of the FUSION Platformexecution in the Build Progress dialog
-timeout <n>
response timeout in seconds for the functions of the FUSION node interface, see FUSION Programmers Guide - tpt_fusion_setFcnResponseTimeOut()
The default FUSION Platform timeout value is 10s. The value can be changed. For example, to increase the value from 10s to 20s enter -timeout 20.